package com.jinandi.app.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/login")
public class LoginController extends BaseController {

	@RequestMapping(value="/index")
	public String login() {
		return "/login/login.ftl";
	}

	@RequestMapping(value = { "/{reason}" }, method = {RequestMethod.GET }, produces = { "text/html;charset=UTF-8" })
	@ResponseBody
	public String loginResult(@PathVariable("reason") String reason,
			Model model, HttpServletRequest request) {
		String message = "-" + reason;
		if ("ve".equals(reason)) {
			message = "-图形校验码输入出错！";
		} else if ("au".equals(reason)) {
			message = "-用户名/密码输入出错！";
		} else if ("ok".equals(reason)) {
			message = "+登录成功！";
		}
		return message;
	}
}
